package Chapter04.Interface;

import java.util.Scanner;

public class Test {
    static IDao dao;
    static Scanner scan;
    static int choice = -1;

    public static void main(String[] args) {
        System.out.println("请选择分公司要使用的数据库\n\n1.MySQl\n2.Oracle\n3.Sqlite\n请选择：");
        scan = new Scanner(System.in);
        choice = scan.nextInt();
        if(choice==1){
            dao = new MYSQLDao();
        }
        else if(choice==2){
            dao = new oracle();
        }
        else if (choice==3){
            dao = new Sqlite();
        }

        /*主菜单循环*/
        boolean flag = true;
        while (flag)
        {
            System.out.println("=====数据库操作菜单=====\n1.增加操作\n2.删除操作\n3.查询操作\n4.修改操作\n0.退出\n请选择：");
            if(flag){
                choice = scan.nextInt();
                switch (choice){
                    case 1:dao.add();break;
                    case 2:dao.delete();break;
                    case 3:dao.select();break;
                    case 4:dao.update();break;
                    case 0:flag = false;break;
                }
            }
        }
    }

}
